package io.renren.modules.student.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.student.entity.TProfessionalEntity;
import io.renren.modules.student.service.TProfessionalService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author huangyan
 * @email yan.huang@jrj.com.cn
 * @date 2021-03-25 12:46:12
 */
@RestController
@RequestMapping("student/tprofessional")
public class TProfessionalController {
    @Autowired
    private TProfessionalService tProfessionalService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("student:tprofessional:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tProfessionalService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{professionalId}")
    @RequiresPermissions("student:tprofessional:info")
    public R info(@PathVariable("professionalId") Long professionalId){
        TProfessionalEntity tProfessional = tProfessionalService.getById(professionalId);

        return R.ok().put("tProfessional", tProfessional);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("student:tprofessional:save")
    public R save(@RequestBody TProfessionalEntity tProfessional){
        tProfessionalService.save(tProfessional);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("student:tprofessional:update")
    public R update(@RequestBody TProfessionalEntity tProfessional){
        ValidatorUtils.validateEntity(tProfessional);
        tProfessionalService.updateById(tProfessional);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("student:tprofessional:delete")
    public R delete(@RequestBody Long[] professionalIds){
        tProfessionalService.removeByIds(Arrays.asList(professionalIds));

        return R.ok();
    }

}
